<script src="<?php echo js_link('jquery.js');?>"></script>
<!-- start content-outer ......................START -->
<div id="content-outer">
<!-- start content -->
<div id="content">

	<!--  start page-heading -->
	<div id="page-heading">
		<h1>Manage Agents</h1>
	</div>
	<!-- end page-heading -->

	<table border="0" width="100%" cellpadding="0" cellspacing="0" id="content-table">
	<tbody><tr>
		<th rowspan="3" class="sized"><img src="<?php ECHO img_link('shared/side_shadowleft.jpg')?>" width="20" height="300" alt=""></th>
		<th class="topleft"></th>
		<td id="tbl-border-top">&nbsp;</td>
		<th class="topright"></th>
		<th rowspan="3" class="sized"><img src="<?php ECHO img_link('shared/side_shadowright.jpg')?>" width="20" height="300" alt=""></th>
	</tr>
	<tr>
		<td id="tbl-border-left"></td>
		<td valign="top">
		<!--  start content-table-inner ...................... START -->
		<div id="content-table-inner">
		
			<!--  start table-content  -->
			<div class="newcust"><a href="<?php echo base_url().'agents/add/';?>" target="_blank" class="new_button" title="New Customer">New Agent</a></div>
			<span class="sercust"><div class="search_button" title="Search Customers">Search Agents</div></span>
			<script>
				function search()
				{
					window.location="<?php echo base_url();?>agents/?username="+$("#username").val()+"&email="+$("#email").val();
				}
			</script>
			<form method="get" action="" onsubmit="search(); return false;">
			<table border="0" cellpadding="7" cellspacing="0">

              <tbody>
              <tr>
              	
                <td align="left">Name:</td>
                <td align="left"><input name="textfield" type="text" class="field" id="username" size="26" value="<?php echo (isset($_GET['username']) ? $_GET['username'] : '');?>"></td>
                <td align="left">Email:</td>
                <td align="left"><input name="textfield6" type="text" class="field" id="email" value="<?php echo (isset($_GET['email']) ? $_GET['email'] : '');?>" size="40"></td>
                <td><button class="large button red">Search</button></td>
              </tr>
            </tbody>
            </table>
            </form>
			<br>
			<table border="1" cellpadding="7" cellspacing="0" style="border-collapse:collapse;" bordercolor="#CCCCCC" ;="">
              <tbody><tr>
                <td class="table-title">No</td>
                <td width="40" align="left" class="table-title">Username</td>
                <td width="260" align="left" class="table-title">Email</td>
                <td width="100" align="left" class="table-title">Group</td>
                <td width="130" align="left" class="table-title">Status</td>
                <td width="130" align="left" class="table-title">Actions</td>
              </tr>
              <?php 
              foreach($rows as $k => $user):
              ?>
              <tr>
                <td><?php echo ($k+1);?></td>
                <td align="left"><?php echo $user->username;?></td>
                <td align="left"><a href="<?php echo base_url().'customer/edit/'.$user->user_id;?>"><?php echo $user->email;?></a></td>
                <td align="left"><?php echo ($user->group_id == 1 ? 'admin' : 'agent');?></td>
                <td align="left"><?php echo $user->status;?></td>
                <td align="center">
                	<a href="<?php echo base_url().'agents/edit/'.$user->user_id;?>">Edit</a>&nbsp;|&nbsp;
                	<a onclick="return confirm('Are you ok?');return false;" href="<?php echo base_url().'agents/del/'.$user->user_id;?>">Delete</a>
                	</td>
              </tr>
              <?php 
              endforeach;
              ?>
            </tbody></table>
			<div class="clear"></div>
		</div>
		<!--  end content-table-inner ......................END  --></td>
		<td id="tbl-border-right"></td>
	</tr>
	<tr>
		<th class="sized bottomleft"></th>
		<td id="tbl-border-bottom">&nbsp;</td>
		<th class="sized bottomright"></th>
	</tr>
	</tbody></table>
	<?php echo $pagnav;?>
	<div class="clear">&nbsp;</div>

</div>
<!--  end content -->